<!--
 * @Author: Bonnie
 * @Date: 2021-08-30 18:10:46
 * @LastEditTime: 2021-10-11 14:36:25
 * @LastEditors: Bonnie
 * @Description: 
 * @FilePath: /custom/src/components/Header.vue
 * 可以输入预定的版权声明、个性签名、空行等
-->

// 该组件为常见页面Header组件
// 可根据实际需求进行修改
<template>
  <div class="header-container pl40 pr40 border-box flex flex-between">
    <div class="left">
      <h2>LOGO</h2>
    </div>
    <div class="right flex flex-center">
      <img
        class="avatar"
        src="https://img.chinasongzhuang.cn/uploadimg/image/20200219/20200219180104_83804.jpg"
      />
      <el-dropdown @command="toOther" trigger="click">
        <span class="el-dropdown-link">
          Bonnie
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item v-for="nav in pathList" :key="nav.id" :command="nav.path">{{nav.desc}}</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>
<script>
export default {
  name: "Header",
  data() {
    return {
      pathList: [
        {
          id: 0,
          path: "/home",
          desc: "首页"
        },
        {
          id: 1,
          path: "/layout",
          desc: "流式布局"
        },
        {
          id: 2,
          path: "/loader-css",
          desc: "加载中1"
        },
        {
          id: 3,
          path: "/css",
          desc: "加载中2"
        },
        {
          id: 4,
          path: "/test",
          desc: "test"
        }
      ]
    };
  },
  methods: {
    toOther(command) {
      const { fullPath } = this.$route;
      if (fullPath == command) return;
      this.$router.push(command);
    }
  }
};
</script>
<style lang='scss' scoped>
.header-container {
  width: 100%;
  height: 70px;
  background-color: #eee;
}
</style>

<style lang='scss' >
// 修改当前组件里的样式
.header-container {
  .left {
  }
  .right {
    .avatar {
      margin-right: 8px;
      width: 38px;
      height: 38px;
      border-radius: 50%;
    }
  }
  .el-dropdown-link {
    color: #b2b6c6;
    cursor: pointer;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
}
// 修改全局样式
.el-dropdown-menu {
  width: 100px;
  border-radius: 10px !important;
  .el-dropdown-menu__item:not(.is-disabled):hover,
  .el-dropdown-menu__item:focus {
    background-color: #f8f9fa !important;
    color: #000 !important;
  }
}
</style>

